//
//  AppDelegate.m
//  WeClubs
//
//  Created by Zed Link on 26/3/2017.
//  Copyright © 2017 Zed. All rights reserved.
//

#import "AppDelegate.h"
#import "AppDelegate+JPush.h"
#import "AppDelegate+RongCloud.h"
#import "ZTabbarController.h"
#import "ZNavigationController.h"
#import "ZLoginVC.h"
#import "HTTPRequest.h"

#import "ThirdPartKeyDefine.h"
#import <SMS_SDK/SMSSDK.h>


@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // ========== 样式设置 ==========
    [self zSetupDefaultStyle];
    
    // ========== 登陆操作判断 ==========
    if ([[ZUserInfo sharedInstance].token isEqualToString:TOKEN_INVALIDATE_DESCRIPTION])
    {
        ZLoginVC *loginVC = [ZLoginVC zNew];
        ZNavigationController *mainVC = [[ZNavigationController alloc] initWithRootViewController:loginVC];
        [self.window setRootViewController:mainVC];
    } else
    {
        ZTabbarController *mainVC = [[ZTabbarController alloc] init];
        [self.window setRootViewController:mainVC];
    }
    
    [self.window makeKeyAndVisible];
    
    // ========== 功能配置 ==========
    [self zThirdPartRegisterAndSetup];
    
    // ========== 获取七牛 ==========
    [HTTPRequest getQiniuConfig];
    
    //==========JPush======
    [self JPushConfigWithLanchOption:launchOptions];
    
//    //==========RongCloud======
//    [self RongCloudConfig];
    
    return YES;
}


#pragma mark - SEL

- (void)zThirdPartRegisterAndSetup
{
    // Mob短信验证
    [SMSSDK registerApp:SMSSDKAppKey withSecret:SMSSDKAppSecret];
}

- (void)zSetupDefaultStyle
{
    // ========== NavBar样式 ==========
    [UINavigationBar appearance].tintColor = NAVBAR_FG_COLOR;
    [UINavigationBar appearance].barTintColor = NAVBAR_BG_COLOR;
    [[UINavigationBar appearance] setTitleTextAttributes:@{
                                                           NSForegroundColorAttributeName : NAVBAR_FG_COLOR,
                                                           NSFontAttributeName : [UIFont systemFontOfSize:NAVBAR_TITLE_SIZE],
                                                           }];
    
    // ========== Tabbar样式 ==========
    [UITabBar appearance].tintColor = TABBAR_FG_COLOR;
    [UITabBar appearance].barTintColor = TABBAR_BG_COLOR;
    
    // ========== 根控制器配置 ==========
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
}




@end
